{% extends "main.html" %}

{% block head %}
    {{ super() }}
{% endblock %}


{% block title %} IP-ASN History {% endblock %}

{% block scripts %}
    {{ super() }}
{% endblock %}

{% block content %}
  <center>
      <h1>IP-ASN History</h1>
  </center>
  <p>
  <form class="form-group" style="width:250px; display:inline-block;" action="" method=post>
    <label for="ip">IP Address</label>
    <input name="ip" class="form-control my-1 mr-sm-2" value="{{ ip }}"/>
    <button type="submit" class="btn btn-primary my-1">Search</button>
  </form>
  </p>
  {% if ipasn_details %}
  <table class="table">
      <tr>
          <th>First Seen</th>
          <th>Last Seen</th>
          <th>ASN</th>
          <th>ASN Description</th>
          <th>Prefix</th>
      </tr>
      {% for entry in ipasn_details %}
      <tr>
          <td>{{ entry['first_seen'] }}</td>
          <td>{{ entry['last_seen'] }}</td>
          <td><a href="{{ url_for('asn_details', asn=entry['asn']) }}">{{ entry['asn'] }}</td>
          <td>
              {% for asn_description in entry['asn_descriptions'] %}
                {{ asn_description }} </br>
              {% endfor %}
          </td>
          <td><a href="{{ url_for('asn_details', asn=entry['asn'], prefix=entry['prefix']) }}">{{ entry['prefix'] }}</td>
      </tr>
      {% endfor %}
  </table>
  {% endif %}
{% endblock %}
